Giter VIP home page Giter VIP logo

tnef's Introduction

Build Status

TNEF

TNEF is a program for unpacking MIME attachments of type "application/ms-tnef". This is a Microsoft only attachment.

Due to the proliferation of Microsoft Outlook and Exchange mail servers, more and more mail is encapsulated into this format.

The TNEF program allows one to unpack the attachments which were encapsulated into the TNEF attachment. Thus alleviating the need to use Microsoft Outlook to view the attachment. Caveat: TNEF does not handle well attachments with non-Unicode filenames or data.

TNEF is mainly tested and used on GNU/Linux and CYGWIN systems. It 'should' work on other UNIX and UNIX-like systems.

See the file COPYING for copyright and warranty information.

See the file INSTALL for instructions on installing TNEF. The short form for installation is the standard:

autoreconf
./configure
make check
make install

'make check' will have created the tnef executable in the src directory and run all the unit tests. 'make install' should have put it into /usr/local/bin. Please see the man page or tnef --help for options.

tnef's People

Contributors

bentley avatar ddeka2910 avatar dtimms avatar ericsesterhennx41 avatar heirecka avatar ilegitimo avatar jengelh avatar joankaradimov avatar pauldreik avatar tekai avatar verdammelt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tnef's Issues

tnef support for recognising / handling e-mail bodies in TNEF format

Hi,
I've been having issue with TNEF format and thought it best to write up what I've found so far. I've been receiving e-mail from a colleague running what I suspect to be a newer Microsoft mail client. These have an "attachment" in TNEF format which (with the aid of a hex editor) turns out to be the HTML formatted (ofcourse) contents of the e-mail. tnef silently "fails" to handle these because:

*. TNEF key is 695e rather than 363
*. There is no attATTACHRENDDATA 0x9002 object, so no file is set-up and hence there is no output, debug or otherwise.
*. However the 0x9003 field is still present and contains a byte stream which is the e-mail.

I'll see if I can get you an example.

Although it may be outside of scope of tnef, would it be possible to warn in verbose or debug mode that the winmail.dat file is not empty but does not contain an attachment? Thanks.

integer underflow in unicode_to_utf8

tnef 1.4.14
tnef -f $file

==11058== Invalid write of size 1
==11058== at 0x41526B: unicode_to_utf8 (util.c:98)
==11058== by 0x40BC14: mapi_attr_read (mapi_attr.c:215)
==11058== by 0x412BD8: parse_file (tnef.c:305)
==11058== by 0x402433: main (main.c:380)

unsigned char*
unicode_to_utf8 (size_t len, unsigned char* buf)
{
int i = 0;
int j = 0;
unsigned char utf8 = malloc (3 * len/2 + 1); / won't get any longer than this */

for (i = 0; i < len - 1; i += 2)
when len is 0, (len - 1) underflow

poc.zip

tnef fails to parse/extract winmail.dat

I'm trying to extract attachments from winmail.dat file by using tnef, but it seems tnef is unable to parse the file for some reason. The file is expected to include calendar invitation, originating from MS Exchange 2010.

$ tnef winmail.dat
$ tnef -f winmail.dat --list
$ tnef -f winmail.dat --list -v
$ tnef -C tempdir -f winmail.dat

eg. all the above output nothing.. If I enable the "--debug" flag then I'll get lots of output, as promised by the usage/help text :)

Any tips about how to get the file contents parsed/extracted? Thanks!

I'm using tnef-1.4.18-1.el7.x86_64 rpm.

On manpage clarify --save-body FILE

On the manpage at

              Save message body data found in the TNEF data. There can

mention if without --save-body will the message body data be saved
anyway or not.

              be up to three message bodies in the file, plain text,
              HTML encoded, and RTF encoded. Which are saved is
              specified by the --body-pref option. By default the
              message bodies are written to a file named message with
              an extension based upon the type (txt, html, rtf).

So maybe there is always an implicit --save-body message turned
on, and --save-body FILE just picks a new name instead of message.
All this needs to be clarified on the man page.

1.4.13 release

There are commits that have the commit message 'release 1.4.13' but there is no actual tag/release. Can you please make one?

Use __builtin_mul_overflow if it exists.

__builtin_mul_overflow will be very fast so we should use it if it exists.

We can check for it it in the code with something like:

#ifdef __GNUC__ # if __GNUC__ >= 5 
# define HAVE_BUILTIN_OVERFLOW 
# elif defined(__has_builtin) /* clang */ 
# if __has_builtin(__builtin_mul_overflow) 
# define HAVE_BUILTIN_OVERFLOW 
# endif 
# endif 
#endif 

Calendar Entries

We have 2 companies under the same umbrella, one of them uses Outlook and Exchange, the other uses Sendmail/Dovecot and combinations of Non-Outlook clients.

The Admin Assistant always sends calendar invites from her Outlook, which stores the invites in a winmail.dat file, and sends them to our Director, who cannot open them.

we use TNEF to extract all attachments, but it is not recognising the Calendar entries embedded in the file

I have a winmail.dat file with calendar entries embedded, if you would like to have a look.

Possible bug in mapi_attr.c assert statement.

Received in email from: Adreas Kainz on 2017-12-14

Hi,

I think you have a bug in mapi_attr.c:

line 49:
assert (len > 16);

this should be:
assert (len >= 16);

I have winmail.dat where the prior assertion triggers.

I didn't fully try to trace why you added this assert and why it
should be 16; anyway, len > 16 looked a little bit suspicious ;-)
and my winmail.dat works with the changed assert.

.ics file not open

Hey @verdammelt ,

I am unable to parse .ics file as it return That was a not TNEF format file error while try to open this file

Sample ics.dat.zip

While this file open in Letter Opner app without any error.

Can you please provide guide that How can I open it?

Thanks

Warnings when running autoreconf

aclocal: warning: autoconf input should be named 'configure.ac', not 'configure.in'
automake: warning: autoconf input should be named 'configure.ac', not 'configure.in'
automake: warning: autoconf input should be named 'configure.ac', not 'configure.in'

On manpage warn of massive --debug output

On the manpage at

       --debug
              enable debug output.

do add a warning that this will alas spew five times the
entire file's worth of bytes upon the screen.

$ ls -og winmail.dat
-rw------- 1 996334 12-05 01:27 winmail.dat
$ tnef --debug --list winmail.dat | wc
    337 1002968 5018665

So add that if the user is not prepared for five megbytes "in the face" he
should at least "pipe it to more(1)".

1.4.13: Assertion `a->type == szMAPI_STRING' / `(idx+(a->names[i].len*2)) <= len' failed

Since Version 1.4.13 we get assertion failures while parsing a winmail.dat containing unicode strings.

Example winmail.dat with debug output from 1.4.12 and 1.4.13: https://gist.github.com/isoftjs/e7eb450b62abbd426b055a540b3685d2


Using 1.4.12:

./tnef-1.4.12/src/tnef --list --file winmail.dat
example.dat |   example.dat

Using 1.4.13:

./tnef-1.4.13/src/tnef --list --file winmail.dat
tnef: file.c:176: file_add_mapi_attrs: Assertion `a->type == szMAPI_STRING' failed.

When adding szMAPI_UNICODE_STRING to the assertion the file can be parsed:

./tnef-1.4.13/src/tnef --list --file winmail.dat
example.dat |   example.dat

With some debug printing after the changed assertion:

./tnef-1.4.13/src/tnef --list --file winmail.dat
file_add_mapi_attrs@178: file->name=example.dat, a->type=31
example.dat |   example.dat

At first the issue was occurring with an incoming mail (which contains some sensitive information) with another assertion failure:

Using 1.4.12:

./tnef-1.4.12/src/tnef --list --file winmail.dat
Filename Jan. 2017 - Kopie.pdf  |   Filename Jan. 2017 - Kopie.pdf
Filename Dez. 2016 - Kopie.pdf  |   Filename Dez. 2016 - Kopie.pdf

Using 1.4.13:

./tnef-1.4.13/src/tnef --list --file winmail.dat
tnef: mapi_attr.c:216: mapi_attr_read: Assertion `(idx+(a->names[i].len*2)) <= len' failed.

Then the assertion failure from the gist above will occur (file.c:176: file_add_mapi_attrs: Assertion a->type == szMAPI_STRING failed.)

With some debugging:

./tnef-1.4.13/src/tnef --list --file winmail.dat
mapi_attr_read@216: idx=8968, a->names[i].len=30, len=9096
mapi_attr_read@216: idx=9048, a->names[i].len=32, len=9096
file_add_mapi_attrs@178: file->name=Filename Jan. 2017 - Kopie.pdf, a->type=31
Filename Jan. 2017 - Kopie.pdf  |   Filename Jan. 2017 - Kopie.pdf
file_add_mapi_attrs@178: file->name=Filename Dez. 2016 - Kopie.pdf, a->type=31
Filename Dez. 2016 - Kopie.pdf  |   Filename Dez. 2016 - Kopie.pdf

On manpage mention what the --list fields are

On the man page at

       -t,  --list
              list attached files, do not extract.

Mention that what one is seeing is indeed one file per line.
And the first column represents ...,
and the second column represents ...,
and thus even though they look similar, careful inspection shows they
aren't.
Also add a tip: to enable the results to fit on one's screen, try
piping to perl -pwle 's/\s+/ /g;'

Also mention that adding -v now gives five or six fields, the first is
the size, the second is the date, the third and fourth are as above.
The fifth is "unknown", perhaps always, and the sixth is perhaps
blank...

Compilation Warnings

gcc -DHAVE_CONFIG_H -I.     -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
main.c:256:30: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
            fprintf (stderr, COPYRIGHTS);
                             ^~~~~~~~~~
1 warning generated.
mv -f .deps/main.Tpo .deps/main.Po
gcc -DHAVE_CONFIG_H -I.     -g -O2 -MT mapi_attr.o -MD -MP -MF .deps/mapi_attr.Tpo -c -o mapi_attr.o mapi_attr.c
mapi_attr.c:208:14: warning: comparison of constant 32768 with expression of type 'mapi_name' (aka 'enum _mapi_name') is always
      false [-Wtautological-constant-out-of-range-compare]
        if (a->name >= GUID_EXISTS_FLAG)
            ~~~~~~~ ^  ~~~~~~~~~~~~~~~~

Error while parsing file with MAPI multi-value fields.

Certain winmail.dat files contain MAPI fields which are 'multi-value' fields. These are inconsistently handled by tnef and case result in a termination of processing with the error message:

!!MULTI_VALUE_FLAG seen (0x1205 0x02)
Assertion failed: (!mvf), function mapi_attr_read, file mapi_attr.c, line 250.
Abort trap: 6

Chinese name issue

if attachments named in Chinese, would not get the right name,

here is the output files name when run tnef winmail.dat

C%C0%E0%CE%EF%C1%CF1.xls  
C%C0%E0%CE%EF%C1%CF2.xlsx 
D%C0%E0%CE%EF%C1%CF.xls

and here is the right name when run tnef -t winmail.dat

btw, I am using Mac OS X

make check fails on FreeBSD

I was trying to upgrade tnef from 1.4.12 to 1.4.17 on FreeBSD ports tree and got one failure on make check.

PASS: help.test
PASS: version.test
PASS: basic.test
PASS: debug.test
PASS: list.test
PASS: verbose.test
PASS: overwrite.test
PASS: directory.test
PASS: maxsize.test
PASS: body.test
PASS: mime-types.test
PASS: stdin.test
============================================================================
Testsuite summary for tnef 1.4.17
============================================================================
# TOTAL: 12
# PASS:  12
# SKIP:  0
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0
============================================================================
PASS: one-file.test
PASS: rtf.test
PASS: two-files.test
PASS: missing-filenames.test
PASS: long-filename.test
PASS: data-before-name.test
PASS: MAPI_OBJECT.test
PASS: MAPI_ATTACH_DATA_OBJ.test
PASS: triples.test
PASS: body.test
PASS: multi-name-property.test
PASS: garbage-at-end.test
FAIL: multi-value-attribute.test
PASS: unicode-mapi-attr.test
PASS: unicode-mapi-attr-name.test
============================================================================
Testsuite summary for tnef 1.4.17
============================================================================
# TOTAL: 15
# PASS:  14
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0
============================================================================
See tests/files/test-suite.log
Please report to [email protected]
============================================================================

Here is the content of test-suite.log

=============================================
   tnef 1.4.17: tests/files/test-suite.log
=============================================

# TOTAL: 15
# PASS:  14
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

FAIL: multi-value-attribute
===========================

\'diff "./multi-value-attribute.output" "./baselines/multi-value-attribute.baseline" > "./multi-value-attribute.diff"\' -- Test Failed!
FAIL multi-value-attribute.test (exit status: 1)

And here is a diff between baseline and output files:

-(MESS) Message Class <8008> [type: word <0007>] [len: 35] = 0x5049 0x2e4d 0x6f4e 0x6574 0x4d2e 0x6369 0x6f72 0x6f73 0x7466 0x562e 0x696f 0x6563 0x616d 0x6c69 0x552e 0x2e4d 0x4143 0x0000
+(MESS) Message Class <8008> [type: word <0007>] [len: 35] = 0x5049 0x2e4d 0x6f4e 0x6574 0x4d2e 0x6369 0x6f72 0x6f73 0x7466 0x562e 0x696f 0x6563 0x616d 0x6c69 0x552e 0x2e4d 0x4143 0xa500

Please let me know if you need more information

Multi-value test failing under Fedora

@dtimms reports:

Just a note that attempting: make check is showing a test failure in:

FAIL: multi-value-attribute.test

Testsuite summary for tnef 1.4.11
============================================================================
# TOTAL: 13
# PASS:  12
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0
============================================================================
See tests/files/test-suite.log

Given this issue relates to improvements for mult-value fields, this might be related to these patches.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.